#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "unistd.h"
#include "sys/types.h"
#include "fcntl.h"

#define LED_ON  1
#define LED_OFF 0


int main(int argc, char *argv[])
{

    int fd,ret_val;
    unsigned char *filename;
    unsigned char data[1];
    if (argc != 3)
    {
        printf("Usage: ERROR\r\n");
        return -1;
    }
    
    filename = argv[1];

    fd = open(filename,O_RDWR);
    if (fd < 0)
    {
        printf("file open failed\r\n");
        return -1;
    }

    data[0] = atoi(argv[2]);

    ret_val = write(fd,data,sizeof(data));
    if (ret_val < 0)
    {
        printf("LED Ctrl Failed\r\n");
        close(fd);
        return -1;
    }
    
    ret_val = close(fd);
    if (ret_val < 0)
    {
        printf("LED close failed\r\n");
        return -1;
    }
    
    return 0;
}